# Tweaks

This file lists some configuration file tweaks, performance tweaks, visual tweaks, and the likes of making your game run better.

## Performance tweaks

Please keep in mind that the minimal specifications also apply for Linux. Do not expect a performance gain compared to Windows native.


#### DXVK

Check whether the latest DXVK version is installed in your `WINEPREFIX`:

* Use default `WINEDEBUG` (no `-all`!) and check the (terminal) output
* Check the file `output_log.txt` in `users\??\AppData\*`, search for `DXVK`

Setup instructions: [TROUBLESHOOTING.md](TROUBLESHOOTING.md#graphics-bugsissues)


#### Esync

Esync will sometimes work faster than Fsync on some specific game/machine combinations ([see here](https://flightlessmango.com/benchmarks/Esync_vs_Fsync)).

Please note that the official Wine builds do not come with Esync support.
One of the following builds is required:

**Lutris:**

 * Select game -> Configure -> Runner options -> "Enable Esync"
 * See also: [Official tutorial](https://github.com/lutris/docs/blob/master/HowToEsync.md)

**Proton:**

 * Enabled by default when running from the Steam library

**wine-staging or custom build:**

 * Add `export WINEESYNC=1` to your script prior to launching the game

If you have access to the terminal output (or logs),
look out for `Esync` mentions to confirm that it's working.


#### GPU bottleneck improvements

1. In-game setting: Disable "Volumetric Fog". Introduces more lag than what's worth it
2. In-game setting: Lower "Shadow Quality". May greatly improve the frame rates
3. Create a file named `dxvk.conf` where `GenshinImpact.exe` resides. Example options for vsync-less (mailbox mode), tearing-free, low latency gameplay:

```
# Change to False on NVIDIA GPUs
dxgi.nvapiHack = True
# Change to 3 for triple buffering (improves performance at the cost of latency)
dxgi.numBackBuffers = 2
dxgi.syncInterval = 0
dxgi.tearFree = True
# More performance
d3d11.constantBufferRangeCheck = False
d3d11.relaxedBarriers = True
d3d11.invariantPosition = False
d3d11.zeroWorkgroupMemory = False
```


#### Loading times

This is an optimization for installations on a slow drive.
You may make Linux' file caching to RAM more aggressive in order reduce loading
times for repetitive actions.

1. Open `etc/sysctl.conf` with an editor like `nano` with sudo.
2. Add the line `vm.vfs_cache_pressure = 10`. Save and exit.
3. Run `sudo sysctl -p` to reload the kernel configuration.


## Visual tweaks

#### Benchmark

* Set the environment variable `DXVK_HUD` to `fps,frametimes`
* For a fancier display, try [MangoHud](https://github.com/flightlessmango/MangoHud) instead.


#### Post Processing using vkBasalt

[vkBasalt](https://github.com/DadSchoorse/vkBasalt) offers cool shaders and re-shade-like features.

1. Disable in-game antialiasing
2. Create a file named `vkBasalt.conf` in the directory where `GenshinImpact.exe` resides.
3. Example file contents to apply a not-so-blurry SMAA and some sharpening:

```
#effects is a colon seperated list of effect to use
#e.g.: effects = fxaa:cas
#effects will be run in order from left to right
#one effect can be run multiple times e.g. smaa:smaa:cas
#cas    - Contrast Adaptive Sharpening
#dls    - Denoised Luma Sharpening
#fxaa   - Fast Approximate Anti-Aliasing
#smaa   - Enhanced Subpixel Morphological Antialiasing
#lut    - Color LookUp Table

# Note: smaa will make in-game text blurry.  If you don't mind losing some crispness
# from the image, remove smaa from here and use the in-game antialiasing.
# In-game SMAA and TAA are really blurry, so make sure to turn up casSharpness to
# something like 0.7
effects = cas:smaa

reshadeTexturePath = "/usr/share/reshade/textures"
reshadeIncludePath = "/usr/share/reshade/shaders"
depthCapture = off

#toggleKey toggles the effects on/off
toggleKey = Home

#casSharpness specifies the amount of sharpning in the CAS shader.
#0.0 less sharp, less artefacts, but not off
#1.0 maximum sharp more artefacts
#Everything in between is possible
#negative values sharpen even less, up to -1.0 make a visible difference
casSharpness = 0.3

#dlsSharpness specifies the amount of sharpening in the Denoised Luma Sharpening shader.
#Increase to sharpen details within the image.
#0.0 less sharp, less artefacts, but not off
#1.0 maximum sharp more artefacts
dlsSharpness = 0.2

#dlsDenoise specifies the amount of denoising in the Denoised Luma Sharpening shader.
#Increase to limit how intensely film grain within the image gets sharpened.
#0.0 min
#1.0 max
dlsDenoise = 0.2

#fxaaQualitySubpix can effect sharpness.
#1.00 - upper limit (softer)
#0.75 - default amount of filtering
#0.50 - lower limit (sharper, less sub-pixel aliasing removal)
#0.25 - almost off
#0.00 - completely off
fxaaQualitySubpix = 0.75

#fxaaQualityEdgeThreshold is the minimum amount of local contrast required to apply algorithm.
#0.333 - too little (faster)
#0.250 - low quality
#0.166 - default
#0.125 - high quality 
#0.063 - overkill (slower)
fxaaQualityEdgeThreshold = 0.125

#fxaaQualityEdgeThresholdMin trims the algorithm from processing darks.
#0.0833 - upper limit (default, the start of visible unfiltered edges)
#0.0625 - high quality (faster)
#0.0312 - visible limit (slower)
#Special notes: due to the current implementation you
#Likely want to set this to zero.
#As colors that are mostly not-green
#will appear very dark in the green channel!
#Tune by looking at mostly non-green content,
#then start at zero and increase until aliasing is a problem.
fxaaQualityEdgeThresholdMin = 0.0312

#smaaEdgeDetection changes the edge detection shader
#luma  - default
#color - might catch more edges, but is more expensive
smaaEdgeDetection = luma

#smaaThreshold specifies the threshold or sensitivity to edges
#Lowering this value you will be able to detect more edges at the expense of performance.
#Range: [0, 0.5]
#0.1 is a reasonable value, and allows to catch most visible edges.
#0.05 is a rather overkill value, that allows to catch 'em all.
smaaThreshold = 0.2

#smaaMaxSearchSteps specifies the maximum steps performed in the horizontal/vertical pattern searches
#Range: [0, 112]
#4  - low
#8  - medium
#16 - high
#32 - ultra
smaaMaxSearchSteps = 8

#smaaMaxSearchStepsDiag specifies the maximum steps performed in the diagonal pattern searches
#Range: [0, 20]
#0  - low, medium
#8  - high
#16 - ultra
smaaMaxSearchStepsDiag = 6

#smaaCornerRounding specifies how much sharp corners will be rounded
#Range: [0, 100]
#25 is a reasonable value
smaaCornerRounding = 80

#lutFile is the path to the LUT file that will be used
#supported are .CUBE files and .png with width == height * height
lutFile = "/path/to/lut"
```

See [original `vkBasalt.conf`](https://github.com/DadSchoorse/vkBasalt/blob/master/config/vkBasalt.conf) for comparison.
